const userService = require("../service/user");
// sql增
const userAddController = async(ctx,next)=>{

    let results = await userService.userAddService(ctx.request.body);
    if (results) {
        ctx.body = {
            code: 200,
            msg: "user select success",
            data: results
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "user select error",
        }
    }

}
// sql删
const userdeleteController = async(ctx,next)=>{

    let results = await userService.userdeleteService(ctx.query.id);
    if (results) {
        ctx.body = {
            code: 200,
            msg: "user delete success",
            data: results
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "user delete error",
        }
    }

}
// sql改
const userupdataController = async(ctx,next)=>{

    let results = await userService.userupdataService(ctx.request.body);
    if (results) {
        ctx.body = {
            code: 200,
            msg: "user updata success",
            data: results
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "user updata error",
        }
    }

}
// sql查
const userselectController = async(ctx,next)=>{

    let results = await userService.userselectService();
    if (results) {
        ctx.body = {
            code: 200,
            msg: "user select success",
            data: results
        }
    } else {
        ctx.body = {
            code: 403,
            msg: "user select error",
        }
    }

}
module.exports={
    userAddController,
    userdeleteController,
    userupdataController,
    userselectController,
}